//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"

const double g = -9.81;

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
	kolo=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Graphics::TBitmap *bitmap=new Graphics::TBitmap;
bitmap->Width=Image->Width;
bitmap->Height=Image->Height;
Image->Picture->Bitmap->Assign(bitmap);
Image->Canvas->Pen->Color=clBlue;
Image->Canvas->MoveTo(0,Image->Height-1);
Image->Canvas->LineTo(Image->Width,Image->Height-1);

}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonStartClick(TObject *Sender)
{
  x=EditX->Text.ToInt();
  y=EditY->Text.ToInt();

  if(kolo==0)

  kolo=new Kolo(Image->Canvas,x,Image->Height-y,5,clRed);
  else
  return;
  t=0;
  Timer->Enabled=true;


}
//---------------------------------------------------------------------------
void __fastcall TForm1::TimerTimer(TObject *Sender)
{
 if (kolo!=0)
 {
 	Timer->Interval=TrackBar->Position;
    t+=Timer->Interval/1000.0;
    int yt=y+ g*t*t/2.0+0.5;
    if(yt>0)
    kolo->przesun(x,Image->Height-yt);
    }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonStopClick(TObject *Sender)
{
	if(kolo!=0)
    {
    	delete kolo;
        kolo=0;
        Timer->Enabled=false;
        }
}
//---------------------------------------------------------------------------
